package com.example.weddingapp.adapter;

import android.text.Html;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import com.example.weddingapp.fragment.ActivityChildFragment;

import java.util.ArrayList;

/**
 * Created by tianyutong on 2016/12/6.
 */

public class MyFragmentPagerAdapter extends FragmentStatePagerAdapter {

    private ArrayList<String> mTitleList = new ArrayList<>(2);
    private ArrayList<Fragment> mFragments = new ArrayList<>(2);


    public MyFragmentPagerAdapter(@NonNull FragmentManager fm, int behavior) {
        super(fm, behavior);
        mTitleList.clear();
        mTitleList.add("未完成");
        mTitleList.add("已完成");
        mFragments.add(ActivityChildFragment.getInstance(0));
        mFragments.add(ActivityChildFragment.getInstance(1));
    }

    @Override
    public Fragment getItem(int position) {
        return mFragments.get(position);
    }

    @Override
    public int getCount() {
        return mFragments.size();
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        super.destroyItem(container, position, object);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if (mTitleList != null && position < mTitleList.size()) {
            return Html.fromHtml(mTitleList.get(position));
        } else {
            return "";
        }
    }


}
